package gui5e;

import java.io.*;	

public class SourceFolder {
	
	//fields
	public File folder;
	
	//constructors
	private SourceFolder(File folder_){
			folder = folder_;
	}
	
	// factory-method
	public static SourceFolder createFolder(String foldername_){
		File folder_ = new File(foldername_);	
		try{
			//checks for the directory and creates it if necessary
			if(! folder_.exists()){
				//System.out.print("folder <"+folder_.getPath()+"> does not exist yet.");
				  if (folder_.mkdirs())  System.out.print("folder <"+folder_.getPath()+"> successfully created.");	 // creates directory and reports success
			}else{
				//System.out.print("folder <"+folder_.getPath()+"> already exists.");
			}
			//return objects to constructor
            return new SourceFolder(folder_);
		}catch (Exception e){	//Catch exception if any
			System.err.println("Error: " + e.getMessage());
			return null;  
		}
	}
	
}
